<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <title>鲜花商城</title>
    <link href="./themes/ecmoban_dangdang/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div id="app">
        <div class="top_nav">
            <div class="block">
                <ul class="top_bav_l">
                </ul>
                <div class="header_r">
                    <font id="ECS_MEMBERZONE" v-if="islogin"> 欢迎光临本站！ <s></s>&nbsp; <span> <a style="color: #FF6766;"
                        href="login.html">[用户登录]</a> <a style="color: #FF6766;" href="register.html">[用户注册]</a>
						<a style="color: #FF6766;" href="slogin.html">[商家登录]</a>
						<a style="color: #FF6766;" href="sregister.html">[商家注册]</a>
                </span>
                    </font>
                    <font id="ECS_MEMBERZONE" v-if="!islogin"> 欢迎鲜花推荐系统 <b>{{ realname }}</b> <span><a
                        style="color: #FF6766;" href="cart.html">[购物车]</a><a style="color: #FF6766;" href="usercenter.html">[用户中心]</a> <a
                        style="color: #FF6766;" href="exit.html">[退出系统] </a> </span>
                    </font>
                </div>
            </div>
        </div>
        <div class="clearfix">
            <div class="block header">
                <div class="top">
                    <a href="index.html" class="logo"><img src="themes/ecmoban_dangdang/images/logo.gif" /></a>
                    <div class="head_r">
                        <div class="top_shopCart clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
        <div style="clear: both"></div>
        <div class="menu_box clearfix">
            <div class="block">
                <div class="menu">
                    <a href="index.html" class="cur" rel="nofollow">网站首页</a>
                    <a href="article.html" class="cur" rel="nofollow">鲜花商城公告</a>
                    <a href="special.html" class="cur" rel="nofollow">特价鲜花</a>
                    <a href="recommend.html" class="cur" rel="nofollow">推荐商品</a>
                    <a href="all.html" class="cur" rel="nofollow">全部鲜花</a>
                </div>
            </div>
        </div>
        <div class="blank"></div>
        <div class="block box">
            <div class="blank"></div>
            <div id="ur_here">
                当前位置: <a href="index.html">首页</a>
                <code> &gt; </code> 个人信息
            </div>
        </div>
        <div class="blank"></div>
        <div class="block clearfix">
            <div class="AreaL">
                <div class="box">
                    <div class="box_1">
                        <div class="userCenterBox">
                            <div class="userMenu">
                                <a href="usercenter.html"><img src="themes/ecmoban_dangdang/images/u2.gif" alt=""/>用户中心</a>
                                <a href="userinfo.html"><img src="themes/ecmoban_dangdang/images/u2.gif" alt=""/>用户信息</a>
                                <a href="editpwd.html"><img src="themes/ecmoban_dangdang/images/u3.gif" alt=""/>修改密码</a>
                                <a href="orderslist.html"><img src="themes/ecmoban_dangdang/images/u3.gif" alt=""/>我的订单</a>
                                <a href="myfav.html"><img src="themes/ecmoban_dangdang/images/u3.gif" alt="" />我的收藏</a>
                                <a href="addcomplains.html"><img src="themes/ecmoban_dangdang/images/u3.gif" alt="" />意见反馈</a>
                                <a href="mycomplains.html"><img src="themes/ecmoban_dangdang/images/u3.gif" alt="" />我的意见反馈</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="AreaR">
                <div class="box">
                    <div class="box_1">
                        <div class="userCenterBox boxCenterList clearfix" style="_height: 1%;">
                            <h5>
                                <span>个人资料</span>
                            </h5>
                            <div class="blank"></div>
                            <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
                                <tr>
                                    <td width="28%" align="right" bgcolor="#FFFFFF">用户名：</td>
                                    <td width="76%" align="left" bgcolor="#FFFFFF">{{username}} <input type="hidden" name="username" id="username" v-model="username" />
                                    </td>
                                </tr>
                                <tr>
                                    <td width="28%" align="right" bgcolor="#FFFFFF">姓名：</td>
                                    <td width="76%" align="left" bgcolor="#FFFFFF"><input name="realname" type="text" size="25" class="inputBg" id="realname" v-model="realname" /></td>
                                </tr>
                                <tr>
                                    <td width="28%" align="right" bgcolor="#FFFFFF">性别：</td>
                                    <td width="76%" align="left" bgcolor="#FFFFFF"><input type="radio" name="sex" value="男" title="男" id="sex" v-model="sex" />男 &nbsp;&nbsp;&nbsp; <input type="radio" name="sex" value="女" title="女" id="sex" v-model="sex" />女</td>
                                </tr>
                                <tr>
                                    <td width="28%" align="right" bgcolor="#FFFFFF">出生日期：</td>
                                    <td width="76%" align="left" bgcolor="#FFFFFF"><input name="birthday" type="text" size="25" class="inputBg" id="birthday" @click="datePicker('birthday')" v-model="birthday" /></td>
                                </tr>
                                <tr>
                                    <td width="28%" align="right" bgcolor="#FFFFFF">联系方式：</td>
                                    <td width="76%" align="left" bgcolor="#FFFFFF"><input name="contact" type="text" size="25" class="inputBg" id="contact" v-model="contact" /></td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center" bgcolor="#FFFFFF"><input type="button" class="bnt_blue_1" style="border: none;" value="确认修改" @click.prevent="toUpdate()" /></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="blank"></div>
        <div id="footer">
            <div class="footer">
                <div class="footer_nav_box">
                    <div class="footer_copyright">
                        <span> &copy;  鲜花商城 版权所有，并保留所有权利。<br /> <br />服务时间：09:00-23:00<br /> <br /> <a href="../admin/index.html"
                            target="_blank">管理员入口</a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<!--此页面业务相关的脚本-->
<script type="text/javascript" src="../admin/assets/layui/layui.js"></script>
<script type="text/javascript" src="../admin/assets/js/axios.min.js"></script>
<script type="text/javascript" src="../admin/assets/js/vue.js"></script>
<script type="text/javascript" src="../admin/assets/js/jquery.min.js"></script>
<script type="text/javascript">
    const vue = new Vue({ // 实例化Vue对象
        el: '#app', // 绑定作用域
        data: { //定义数据 用于vue的双向绑定
            islogin: '',
            userid: '',
            username: '', // 用户名
            realname: '', // 定义姓名数据
            sex: '男', // 定义性别数据
            birthday: '', // 定义出生日期数据
            contact: '', // 定义联系方式数据
            regdate: '',
            users: {},
        },
        methods: {
            datePicker: function(elementId) {
                let vueObj = this;
                WdatePicker({
                    el: elementId,
                    dateFmt: 'yyyy-MM-dd', //日期格式，可以只显示年或年月，也可以额外显示时间
                    onpicked: function() {
                        var value = $("#" + elementId).val();
                        vueObj.birthday = value;
                    },
                    oncleared: function() {
                        vueObj.birthday = null;
                    },
                    isShowClear: true,
                    readOnly: true
                });
            },
            loadPage: function() {
                let _this = this;
                _this.userid = sessionStorage.getItem('userid');
                _this.islogin = sessionStorage.getItem('userid') == null;
                _this.realname = sessionStorage.getItem('realname');
                axios.get('http://127.0.0.1:8080/vue_gxhfztjxt/index/userinfo.action?id=' + _this.userid).then(result => {
                    _this.username = result.data.users.username;
                    _this.realname = result.data.users.realname;
                    _this.sex = result.data.users.sex;
                    _this.birthday = result.data.users.birthday;
                    _this.contact = result.data.users.contact;
                });
            },
            toUpdate: function() {
                let _this = this;
                var data = {
                    usersid: _this.userid,
                    username: _this.username,
                    realname: _this.realname,
                    sex: _this.sex,
                    birthday: _this.birthday,
                    contact: _this.contact,
                };
                axios.post('http://127.0.0.1:8080/vue_gxhfztjxt/index/personal.action', data).then(result => {
                    if (result.data.code > 0) {
                        alert('修改成功');
                        this.loadPage();
                    } else {
                        alert('修改失败');
                    }
                });
            }
        },
        created() { // 生命周期相关的函数
            this.loadPage();
        },
    })
</script>

</html>